//used with interrupts
#define enabled 			0
#define masked 				1
#define PIC_MASK 			0x21
#define PIC_CMD 			0x20
#define EOI 				0x20

//used for comm addresses
#define COM1_INT_ID 		0x0c
#define COM1_BASE 			0x3F8
#define COM1_INT_EN 		COM1_BASE+1
#define COM1_BRD_LSB 		COM1_BASE
#define COM1_BRD_MSB 		COM1_BASE+1
#define COM1_INT_ID_REG 	COM1_BASE+2
#define COM1_LC 			COM1_BASE+3
#define COM1_MC 			COM1_BASE+4
#define COM1_LS 			COM1_BASE+5
#define COM1_MS 			COM1_BASE+6

//used with dcb
#define OPEN				1
#define CLOSED				3
#define IDLE				0
#define READING				2
#define WRITING				4

//error codes used with com_open
#define R5_ERR_EVENT_FLAG 	-101
#define R5_ERR_BAUD_RATE 	-102
#define R5_ERR_PORT_OPEN 	-103

//error code used with com_close
#define R5_ERR_NOT_OPEN		-201

//error codes used with com_read (same as com_write but different codes)
#define	R5_ERR_PORT_CLOSED	-301
#define R5_ERR_INV_BUF_ADD	-302
#define R5_ERR_INV_CNT_ADD	-303
#define R5_ERR_DEV_BUSY		-304

//error codes used with com_write
#define R5_ERR_CLOSED	 	-401
#define R5_ERR_BUFF		 	-402
#define R5_ERR_COUNT	 	-403
#define R5_ERR_BUSY			-404

//miscellaneous
#define R5_RING_BUFF_SIZE	1024


int com_open(int *eflag_p, int baud_rate);
int com_close(void);
int com_write(char *buf_p, int *count_p);
int com_read(char *buf_p, int *count_p);


void interrupt io();

void readio();
void writeio();